#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QPixmap>
#include <QBrush>
#include <QPalette>
#include <QDir>
#include <QPainter>
#include <QColor>
#include <QIcon>
#include <QFileDialog>
#include <QString>
#include <QThread>
//temp----->
#include <iostream>
#include "myframe.h"
using namespace std;
//-------<

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit Dialog(QWidget *parent = 0);
    QString getPath();
    ~Dialog();

public slots:
    void mousePressedA();
    void mouseEnteredA();
    void mouseLeavedA();
    void mousePressedB();
    void mouseEnteredB();
    void mouseLeavedB();
    void mousePressedC();
    void mouseEnteredC();
    void mouseLeavedC();
    void mousePressedD();
    void mouseEnteredD();
    void mouseLeavedD();
    void mousePressedE();
    void mouseEnteredE();
    void mouseLeavedE();
//imageFrame listener functions
    void mousePressedImage();
    void mouseReleaseImage();
    void mouseMovingImage();

    void mouseEnteredLeft();
    void mouseEnteredRight();
    void mouseLeavedLeft();
    void mouseLeavedRight();
    void mousePressedOpenImage();
    void mousePressedOpenDir();
    void mousePressedRemoveA();
    void mousePressedRemoveB();
    void mousePressedRemoveC();
    void mousePressedRemoveD();
    void mousePressedRemoveE();
    void mousePressedLeft();
    void mousePressedRight();

//patterns arrows listeners
    void mousePatternEnteredUp();
    void mousePatternEnteredDown();
    void mousePatternLeavedUp();
    void mousePatternLeavedDown();
    void mousePatternPressedUp();
    void mousePatternPressedDown();

//start search
    void mouseButtonStart();

    void showImages();
    void removeImage(int);
    void loadMainFrame(int);

private:
    QString path;
    Ui::Dialog *ui;
    int startX, startY, endX, endY;

//which category is on image
    bool category[100];

//loading the config file image results
    QStringList getImageInformation(QString);
    void loadSearchResult(QString);

//save to the config file new match
    void saveNewMatch(QString, int, int, int, int, int);

//fill the patterns
    void fillPattern();
    void setPatternCategory();
    void setPatternFrames();

//add new images to list
    QString openImage();
    QString openFolder();

    int firstImage;
    QList<QImage> imagesList;
    QList<MyFrame*> frameList;

    QStringList imagesPath; //contain all loaded images path

    QList<MyFrame*> patternsFrame;   //contains patters pictures
    QStringList patternsPath;   //contains patters path
    int actualPattern, numberOfPatterns;  //point to first pattern
};

class Sleeper : public QThread{
public:
    static void usleep(unsigned long usecs){QThread::usleep(usecs);}
    static void msleep(unsigned long msecs){QThread::msleep(msecs);}
    static void sleep(unsigned long secs){QThread::sleep(secs);}
};

#endif // DIALOG_H
